package cn.bonoon.kernel.support.services.handler;

import javax.persistence.EntityManager;

import cn.bonoon.kernel.events.OperateEvent;
import cn.bonoon.kernel.support.entities.Persistable;

public interface EditHandler {
	EditHandler standard = new EditHandler(){

		@Override
		public boolean insertHandler(EntityManager entityManager, OperateEvent event, Persistable entity) {
			entityManager.persist(entity);
			return true;
		}

		@Override
		public boolean updateHandler(EntityManager entityManager, OperateEvent event, Persistable entity) {
			entityManager.merge(entity);
			return true;
		}
		
	};
	
	boolean insertHandler(EntityManager entityManager, OperateEvent event, Persistable entity);
	
	boolean updateHandler(EntityManager entityManager, OperateEvent event, Persistable entity);
}
